package com.kancy.springcloudconfig.action;

import com.kancy.springcloudconfig.action.model.AlgorithmData;
import com.kancy.springcloudconfig.action.model.RefreshObject;
import com.kancy.springcloudconfig.util.Base64Util;

/**
 * <p>
 * CipherAlgorithAction
 * </p>
 *
 * @author: kancy
 * @date: 2019/10/26 14:09
 **/
public class Base64AlgorithAction extends AbstractAlgorithmAction {


    /**
     * 解密逻辑
     *
     * @param data
     */
    @Override
    protected String decrypt(AlgorithmData data) {
        return Base64Util.decode(data.getCipherText());
    }

    /**
     * 加密逻辑
     *
     * @param data
     */
    @Override
    protected String encrypt(AlgorithmData data) {
        return Base64Util.encodeString(data.getPlainText());
    }


    @Override
    protected void update(RefreshObject object) {
        object.getPasswordObject().setVisible(false);
        object.getSaltObject().setVisible(false);
        object.getLabel1Object().setVisible(false);
        object.getLabel2Object().setVisible(false);
    }
}
